<template>
  <div class="us">
    <!--  :style="'left: calc(calc('+clientWidth+'px - 1400px) / 2);top:'+clientTop+'px;'" -->
    <div
      class="us-box"
    >
      <div class="us-box-text">
        <div class="us-box-text-title">联系方式</div>
        <div class="us-box-text-item">
          <div class="us-box-text-icon">
            <img style="width: 17px;height: 16px;" src="../../images/phone.png" alt />
          </div>
          <div class="us-box-text-phone">
            <p v-for="(item,index) in infoData.phoneStr" :key="index">{{ item.name }}:{{ item.tel }}</p>
          </div>
        </div>
        <div class="us-box-text-item" style="margin-top:26px;">
          <div class="us-box-text-icon">
            <img style="width: 21px;height: 16px;" src="../../images/mailbox.png" alt />
          </div>
          <div class="us-box-text-phone">
            <p>{{ infoData.email }}</p>
          </div>
        </div>
        <div class="us-box-text-title" style="margin-top:100px;margin-bottom: 49px;">我们的位置</div>
        <div class="us-box-text-item" style="margin-top:26px;">
          <div class="us-box-text-icon">
            <img style="width: 18px;height: 22px;" src="../../images/map_logo.png" alt />
          </div>
          <div class="us-box-text-phone">
            <p>{{ infoData.address }}</p>
          </div>
        </div>
      </div>
      <div class="us-box-map">
        <img :src="infoData.image" alt width="100%" />
      </div>
    </div>
  </div>
</template>
<script>
import { contact } from "@/utils/api";
export default {
  name: "ContactUs",
  data() {
    return {
      clientWidth: 1440, //页面宽度
      infoData: {},
      clientTop: 390, //定位高度
      screenWidth: null
    };
  },

  created() {
    // 页面总宽度
    if (document.documentElement.clientWidth >= 1440) {
      this.clientWidth = document.documentElement.clientWidth;
    }

    this.init();
  },
  mounted() {
    //获取屏幕尺寸
    this.screenWidth = document.body.clientWidth;
    window.onresize = () => {
      // console.log("高度");
      //屏幕尺寸变化
      return (() => {
        this.screenWidth = document.body.clientWidth;
      })();
    };
  },

  watch: {
    screenWidth: function(n) {
      if (n >= 1440) {
        this.clientWidth = document.body.clientWidth;
      } else {
        this.clientWidth = 1440;
      }
      console.log(n);
      if (n > 1440) {
        this.clientTop = 390;
        this.clientTop += parseInt((n - 1440) / 3.6);
        console.log(n);
      }
    }
  },
  methods: {
    init() {
      contact({}, res => {
        if (res.code === 200) {
          res.data.phoneStr = JSON.parse(res.data.phoneStr);
          this.infoData = res.data;
        }
      });
    }
  }
};
</script>
<!-- 1903  1441 462 117 -->
<style lang='scss' scoped>
.us {
  max-width: 1920px;
  min-width: 1440px;
  margin: auto;
  min-height: calc(100vh - 928px);
  margin-top: 80px;
  // background: red;
  &-box {
    // position: absolute;
    width: 1400px;
    height: 650px;
    margin: auto;
    background-color: #fff;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    // outline: 1px solid red;
    &-text {
      flex: 1;
      height: 610px;
      margin-right: 30px;
      padding-left: 80px;
      padding-top: 90px;
      &-title {
        font-size: 16px;
        font-weight: bold;
        color: #333333;
      }
      &-item {
        display: flex;
        align-items: flex-start;
        margin-top: 49px;
      }
      &-icon {
        margin-right: 28px;
      }
      &-phone {
        font-size: 16px;
        font-weight: 500;
        color: #666666;
        > p {
          margin-bottom: 23px;
        }
      }
    }
    &-map {
      width: 936px;
      height: 610px;
      overflow: hidden;
    }
  }
}
</style>